package de.webtech.faceplace.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author Julian
 * 
 * Nachrichten welche in der Timeline jedes Nutzers angezeigt werden.
 */
public class Messages implements Serializable {

	//Nachrichten Text
	public String message;
	//Person
	public Person person;
	//Typ der Nachricht
	public int type;
	
	private String author;
	
	private Date date;
	
	private List<Comments> comments;
	
		
	/**
	 * selbsterklärend
	 */
	public Messages(String message, Person person, int type)	{
		this.message = message;
		this.person = person;
		this.type = type;
		this.author= person.firstName + " "+ person.lastName;
		date= new Date();
		comments = new ArrayList<Comments>();
	}

	public String getMessage() {
		return message;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}

	public Person getPerson() {
		return person;
	}

	public int getType() {
		return type;
	}
	
	public String toString()	{
		String text = this.message;
		return text;
	}
	
	public String getAuthor()
	{
		return author;
	}
	
	@SuppressWarnings("deprecation")
	public String getDate()
	{
		return date.toGMTString();
	}
	
	public List<Comments> getComments()	{
		return comments;
	}
	
	public void pushComment(Comments c)	{
		comments.add(c);
	}
	
	public int compareTo(Messages m) {
	    return getDate().compareTo(m.getDate());
	  }
	
}
